﻿using NoteSystem.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NoteSystem
{
    public partial class Reply : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //往回复表插入一条数据
            DataRow userRow = (DataRow)Session["User"];
            int loginUser =Convert.ToInt32(userRow["id"]);//session
            int commentId = Convert.ToInt32(Request["cid"]);
            string detail = TextBox1.Text.Trim();

            int flag = DbHelper.ExecuteSql($"insert into replys values({loginUser},{commentId},'{detail}','{DateTime.Now}')");
            if (flag != 0)
            {
                Response.Write("<script>alert('回复成功')</script>");
            }
            //insert
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.opener.location.reload();window.close();</script>");

        }
    }
}